<template>
  <div>
<h1>x的坐标{{ x }}</h1>
<h2>y的坐标{{ y }}</h2>
  </div>
</template>

<script lang="ts">
import { defineComponent ,onMounted,onUnmounted,ref} from 'vue'
import   useGetMousePosition from './hooks/useGetMousePosition'
export default defineComponent({
  setup () {
      // const x =ref(0);
      // const y =ref(0);
      // const updataPosition=(e:MouseEvent)=>{
      //   x.value=e.pageX;
      //   y.value=e.pageY
      // }
      // onMounted(()=>{
      //   document.addEventListener('click',updataPosition)
      // });
      // onUnmounted(()=>{
      //   document.removeEventListener('click',updataPosition)
      // });
      console.log(useGetMousePosition());
      const { x, y } = useGetMousePosition();
      return {
          x,
          y
      };
  },
})
</script>

<style scoped>

</style>